﻿@model TermAdminIndexViewModel
@using Contrib.Taxonomies.Helpers;
@using Contrib.Taxonomies.ViewModels;

@{
    Style.Include("admin-taxonomy.css");
    Layout.Title = T("Manage terms for {0}", Model.Taxonomy.Name).ToString();

	int termIndex = 0, ti;
}

@using(Html.BeginFormAntiForgeryPost()) {
	@Html.ValidationSummary()
	@Html.HiddenFor(m=>m.TaxonomyId)
	<fieldset class="bulk-actions">
		<label for="publishActions">@T("Actions:")</label>
		<select id="publishActions" name="@Html.NameOf(m => m.BulkAction)">
			@Html.SelectOption(Model.BulkAction, TermsAdminIndexBulkAction.None, T("Choose action...").ToString())
			@Html.SelectOption(Model.BulkAction, TermsAdminIndexBulkAction.Delete, T("Remove").ToString())
		</select>
		<input class="button" type="submit" name="submit.BulkEdit" value="@T("Apply")" />
	</fieldset>
	<div class="manage">@Html.ActionLink(T("Add a term").ToString(), "SelectTerm", new { taxonomyId = Model.Taxonomy.Id }, new { @class = "button primaryAction" })</div>
	<fieldset>
		<table class="items" summary="@T("This is a table of the terms in your application")">
			<colgroup>
				<col id="Col1" />
				<col id="Col2" />
			</colgroup>
			<thead>
				<tr>
					<th scope="col">@T("Name")</th>
					<th scope="col"></th>
				</tr>
			</thead>
				@foreach ( var termEntry in Model.Terms) {
					ti = termIndex;
			<tr>
				<td>
					<input type="hidden" value="@Model.Terms[termIndex].Id" name="@Html.NameOf(m => m.Terms[ti].Id)"/>
					@* Tabs for levels *@ @for ( var i = 1; i <= termEntry.GetLevels(); i++ ) { <span class="gap">&nbsp;</span> }
					<input type="checkbox" value="true" name="@Html.NameOf(m => m.Terms[ti].IsChecked)"/>
					@Html.ItemDisplayLink(termEntry.Name, termEntry.ContentItem)
				</td>
				<td>
				@Html.ItemEditLink(T("Edit").Text, termEntry.ContentItem, new { returnUrl = Url.Action("Index", "TermAdmin", new { taxonomyId = Model.Taxonomy.Id }) }) |
				@Html.ActionLink(T("Move").ToString(), "MoveTerm", new { taxonomyId = Model.Taxonomy.Id, termId = termEntry.Id })
				</td>
			</tr>
				termIndex++;
			}
		</table>
	</fieldset>
}